﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script type="text/javascript">
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        $('select').bindSelect();
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/BOM/Product/GetArrangeComponentJson",
            height: $(window).height() - 120,
            colModel: [
                {
                    label: '<a id="grid_chb_selectAll" onclick="grid_chb_selectAll()">全选</a>', name: 'TH', width: 40, align: 'center', sortable: false, frozen: true, formatter: function (cellvalue, options, rowObject) {
                        return '<input class="grid_chb_select" value="' + rowObject.TH + "|" + rowObject.MC + '" name="checkbox" type="checkbox" onclick="" style="vertical-align:middle">';
                    }
                },
                { label: '产品编号', name: 'TH', width: 140, align: 'left', sortable: false },
                { label: '产品名称', name: 'MC', width: 240, align: 'left', sortable: false },
                { label: '版本', name: 'BB', width: 40, align: 'center', sortable: false },
                { label: '版次', name: 'BC', width: 40, align: 'center', sortable: false },
                {
                    label: '说明', name: 'IsSelect', width: 60, align: 'center', sortable: false, formatter: function (cellvalue) {
                        return cellvalue == "1" ? "已选" : "";
                    }
                },
                { label: '整理人员', name: 'FCreateBy', width: 80, align: 'left', sortable: false },
                { label: '整理日期', name: 'FCreateDate', width: 80, align: 'center', sortable: false },
                { label: '整理时间', name: 'FCreateTime', width: 80, align: 'center', sortable: false },
                { label: '备注', name: '', width: 20, align: 'center', sortable: false }
            ],
            sortname: 'TH asc',
            viewrecords: true,
            rowNum: 500,
            rownumWidth: 40,
            onSelectRow: function (rowid) {
                //var rowData = $gridList.jqGrid('getRowData', rowid);
                //alert(rowData.TH);
            }
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function grid_chb_selectAll() {
        var txt = $('#grid_chb_selectAll').text();
        if (txt == "全选") {
            $('.grid_chb_select').prop("checked", true);
            $('#grid_chb_selectAll').text("反选");
        } else {
            $('.grid_chb_select').prop("checked", false);
            $('#grid_chb_selectAll').text("全选");
        }

    }
    function btn_ok() {
        var array = [];
        $('.grid_chb_select').each(function () {
            if ($(this).prop("checked")) {
                array.push($(this).val());
            }
        });
        if (array.length <= 0) {
            $.modalAlert("请先勾选待整理的零件信息。", "warning");
        }
        else {
            $('#arrangeData').val(array.join(","));
            var title = '是否确定要对以下零件进行整理';
            var url = '/BOM/Product/ArrangeComponentConfig';
            $.detailOpenTop({
                id: "Detail",
                title: title,
                url: url,
                width: 640,
                height: 360
            });
        }
    }
    function submitArrange(idsArray) {
        $.submitForm({
            url: "/BOM/Product/SubmitArrangeComponentInput",
            param: { ids: idsArray.join(',') },
            success: function () {
                $("#gridList").jqGrid('setGridParam', {
                    postData: { keyword: $("#txt_keyword").val() },
                }).trigger('reloadGrid');
            }
        })
    }
    function getArrangeData() {
        return $('#arrangeData').val();
    }
    function btn_cancel() {
        parent.$.detailClose();
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <input id="arrangeData" type="hidden" value="" />
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc; " class="line-table input-width-185">
            <div class="btn-group dialog-title">
                产品零件清单整理计算
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                产品编号<br /><input id="txt_keyword" name="txt_keyword" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 检索</a>
            </div>
            <div class="btn-group" style="float:right;padding-right:50px">
                <a id="btn_reload" class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span> 刷新</a>
                <a id="btn_ok" class="btn btn-primary center-block" onclick="btn_ok()"><span class="glyphicon glyphicon-ok"></span> 整理</a>
                <a id="" class="btn btn-primary center-block disabled" onclick=""><span class="glyphicon glyphicon-download"></span> 导出</a>
                <a id="btn_cancel" class="btn btn-primary center-block" onclick="btn_cancel()"><span class="glyphicon glyphicon-remove"></span> 返回</a>
            </div>
        </div>
    </form>
    <div style="">
        <table id="gridList"></table>
    </div>
    <div style="text-align:right;padding:10px 50px;border-top:1px solid #ccc;">

    </div>
</div>



